Give error when no filename is passed to xfopen.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 15 Feb 2004 19:04:52 +0000 (19:04 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 15 Feb 2004 19:04:52 +0000 (19:04 +0000)
Magellan/windows - fix crash opening non-existent file.

gpsbabel/Makefile
gpsbabel/magproto.c
gpsbabel/util.c

index 7167fa63def02b0fd1c99bdd58beccb965c25b94..2a1c8376c6a4021d2bfbe45eb9587835b563ac62 100644 (file)
@@ -3,7 +3,7 @@
 # type that is XML-ish (i.e. gpx or geocaching.com's/loc) you can uncomment
 # INHIBIT_EXPAT and coment out LIBEXPAT on just to get a build working quickly.
 # INHIBIT_EXPAT=-DNO_EXPAT
-LIBEXPAT=-lexpat # -lefence
+LIBEXPAT=-lexpat #-lefence
 
 #
 # Enable either or both of these as you wish.
@@ -78,8 +78,8 @@ dep:
        (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)' ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_2_1_beta01312004
-VERSIOND=1.2.1_beta01312004
+VERSIONU=1_2_2_beta02152004
+VERSIOND=1.2.2_beta02152004
 #VERSIONU=1_2_1
 #VERSIOND=1.2.1
 
index 1db4b91a8f2669995afab720a6690d910c293e31..c0f09945265a7a6a17c4b9671669bdff238a62ef 100644 (file)
@@ -508,8 +508,7 @@ terminit(const char *portname)
                          OPEN_EXISTING, 0, NULL);
 
        if (comport == INVALID_HANDLE_VALUE) {
-               is_file = 1;
-               return 0;
+               goto try_as_file;
        }
        tio.DCBlength = sizeof(DCB);
        GetCommState (comport, &tio);
@@ -537,6 +536,7 @@ terminit(const char *portname)
                /*
                 *  Probably not a com port.   Try it as a file.
                 */
+try_as_file:
                magfile_in = xfopen(portname, "rb", MYNAME);
                is_file = 1;
                icon_mapping = map330_icon_table;
index 354ace1c3fcadc9110f13de3266496f5c06827c4..bbdc53fbff8e5fa5c5f9cc0ec2048f3dc1832151 100644 (file)
@@ -230,6 +230,11 @@ xfopen(const char *fname, const char *type, const char *errtxt)
        FILE *f;
        int am_writing = strchr(type, 'w') != NULL;
 
+       if (fname == NULL) {
+               fatal("%s must have a filename specified for %s.\n",
+                               errtxt, am_writing ? "write" : "read");
+       }
+
        if (0 == strcmp(fname, "-"))
                return am_writing ? stdout : stdin;
        f = fopen(fname, type);